const { toUrl,globalData } = getApp();
import { request } from "@/utils/request";
Page({
  toUrl,
  data: {
    dataList: [],
    page: 1,
    userInfo: {},
    isEnd: false,
    count: 0,
    globalData
  },
  getDatail() {
    if (this.data.page > 1 && this.data.page > this.data.count) {
      this.setData({
        isEnd: true,
      });
      return;
    }
    let data = {
      page: this.data.page,
    };
    request("user/growthlist", { data }).then((res) => {
      if (res.errcode == 1) {
        let page = this.data.page + 1;
        let list = this.data.dataList;
        if (data.page > 1) {
          res.data.forEach((it, idx) => {
            list.push(it);
          });
          this.setData({
            dataList: list,
            page,
            count: res.count,
          });
        } else {
          this.setData({
            dataList: res.data,
            page,
            count: res.count,
          });
        }
      }
      request("user/getuserinfo").then((res) => {
        if (res.errcode == 1) {
          console.log('用户信息');
          getApp().globalData.baseInfo = res.data
          this.setData({
            userInfo:getApp().globalData.baseInfo
          })
        }
      });
  
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      userInfo:getApp().globalData.baseInfo
    })
    this.getDatail();
  },

  onReachBottom() {
    let isEnd = this.data.isEnd;
    if (isEnd) {
      return;
    } else {
      this.getDatail();
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
